<?php
/**
 * @filesource								ReserveRequestModel.class.php
 * @desc									墓地预订模型类 
 * 
 * @author									houyining
 * @copyright								hou.yining@gmail.com
 * @date									2011-05-06
 */

class ReserveRequestModel extends CommonModel{
	protected $_auto = array(
		array('create_time', 'time', MODEL::MODEL_INSERT, 'function'),
		array('creater_id', 'get_current_operator', MODEL::MODEL_INSERT, 'function'),
		array('reserve_start', 'getStartTime', MODEL::MODEL_BOTH, 'callback'),
		array('reserve_end', 'getEndTime', MODEL::MODEL_BOTH, 'callback'),
		array('status',1),
	);
	
	//根据指定id获取预留的详细信息
	public function getReserveRequestById($id){
		$rs = $this->db->query("select a.name as customer_name, b.* from ".
								$this->tablePrefix."reserve_request as b,".
								$this->tablePrefix."general_customer as a ".
								"where b.id=".$id . " and a.id=b.applicant_id");
		return $rs;
	}
	
	//根据申请人的id获取所有预留记录
	public function getReserveRequestByApplicant($applicant_id){
		return $this->where(array('applicant_id' => $applicant_id))->select();
	}
	
}
?>